package com.itnoob.command1.example.task;

import com.itnoob.command1.example.service.ProductService;
import com.itnoob.command1.example.service.StockService;

/**
 * 具体命令类
 * @author zhoujun
 * @date 2025/3/18 23:24
 */
public class GetStockTask implements Task {

    private StockService stockService;

    private  int productId;

    public GetStockTask(StockService stockService, int productId) {
        this.stockService = stockService;
        this.productId = productId;
    }

    @Override
    public Object call() throws Exception {
        //调用接受者获取库存的方法,并返回结果
        return stockService.getStock(productId);
    }
}
